<html>
<head>
    <script>
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.waitUntilDone();
        }

        function loaded()
        {
            var beenHere = document.getElementById("beenHere");
            var input = document.getElementById("input");

            if (beenHere.value) {
                var result = "FAIL";
                // Button value is not restored.
                if (input.value == "PASS") {
                    beenHere.value = "PASS";
                    result = "PASS";
                }

                document.getElementById("result").innerText = result;

                if (window.testRunner)
                    testRunner.notifyDone();
                return;
            }

            beenHere.value = "FAIL";

            input.value = "FAIL";

            var form = document.getElementById("form");

            // Submit form in a timeout to make sure that we create a new back/forward list item.
            setTimeout(function() {form.submit();}, 0);
        }
    </script>
</head>
<!-- the unload handler keeps this page out of the B/F cache -->
<body onunload="" onload="setTimeout(loaded, 1)">
    <p>
        This is a test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=14400">http://bugs.webkit.org/show_bug.cgi?id=14400</a>
        Assertion failure (SHOULD NEVER BE REACHED) going back on YouTube</i>.
    </p>
    <p>
        Test result: <span id="result">test did not complete</span>
    </p>
    <button type="button" name="foo">Button</button>
    <input id="input" type="button" name="foo" value="PASS">
    <input id="beenHere">
    <form action="../../resources/back.html" method="POST" id="form"></form>
</body>
</html>
